package com.fqgj.xjd.user.dao.impl;

import com.fqgj.common.api.Page;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.common.utils.StringUtils;
import com.fqgj.xjd.user.dao.UserBehaviorFeedbackDao;
import com.fqgj.xjd.user.entity.UserBehaviorFeedbackEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * User: zhangxingyun
 * Date: 2017-07-27
 * Time: 22:23:17.106
 */

@Repository
public class UserBehaviorFeedbackDaoImpl extends AbstractBaseMapper<UserBehaviorFeedbackEntity> implements UserBehaviorFeedbackDao {

    @Override
    public List<UserBehaviorFeedbackEntity> selectUserFeedbackByPage(Page page, Integer status, Integer ownerId, Integer noticeStatus, String appCode) {
        Map param = new HashMap();
        param.put("page", page);
        param.put("status", status);
        param.put("ownerId", ownerId);
        param.put("noticeStatus", noticeStatus);
        param.put("appCode", appCode);
        page.setTotalCount(getSqlSession().selectOne("countUserFeedBack", param));
        return getSqlSession().selectList("selectUserFeedbackByPage", param);
    }


    @Override
    public List<UserBehaviorFeedbackEntity> selectUserFeedbackByUserCode(String userCode) {
        if (StringUtils.isEmpty(userCode)) {
            return null;
        }

        Map param = new HashMap();
        param.put("userCode", userCode);
        return getSqlSession().selectList("selectUserFeedbackByUserCode", param);
    }

    @Override
    public int countUserFeedBack(Integer status, Integer ownerId) {
        Map param = new HashMap();
        param.put("status", status);
        param.put("ownerId", ownerId);
        return getSqlSession().selectOne("countUserFeedBack", param);
    }

    @Override
    public int updateByIds(List<Long> ids) {
        return getSqlSession().update(getStatement("updateByIds"), ids);
    }
}